<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.global.js'></script>
</head>

<body>
    <div id='app'>
        <!-- 查询变量activeClass与errorClass对应的值 得到div的class们 -->
        <div :class="['active', 'text-danger']">1</div>
        <div :class="[activeClass, errorClass]">11</div>

        <!--  -->
        <div :class="[isActive ? 'active' : 'nobird', errorClass]">2</div>
        <div :class="['nobird', 'text-danger']">22</div>

        <!-- 
        综合案例：
        'current'：
            div有一个class名曰current
        errorClass
            值为'text-danger' 所以div有一个class名曰text-danger
        { active: isActive,shit:activeClass }
            isActive不成立 div没有active这个class
            activeClass成立 div有shit这个class
        -->
        <div :class="['current',errorClass,{ active: isActive,shit:activeClass }]">3</div>
        <div :class="['current','text-danger','active','shit']">33</div>
    </div>

    <script>
        const app = Vue.createApp({
            data() {
                return {
                    isActive:true,
                    activeClass: 'active',
                    errorClass: 'text-danger'
                }
            },
            computed: {
                classObjectComputed() {
                    return {
                        active: this.isActive && !this.error,
                        'text-danger': this.error && this.error.type === 'fatal'
                    }
                }
            }
        })
        const vm = app.mount('#app')
    </script>
</body>

</html>